import { defineStore } from "pinia";
import request from "@/utils/http";
import type { ApiRes, CategoryList } from "@/types/data";

const useHomeStore = defineStore("home", {
  state: () => ({
    categoryList: [] as CategoryList,
  }),
  actions: {
    async getAllCategory() {
      const res = await request.get<ApiRes<CategoryList>>(
        "/home/category/head"
      );
      this.categoryList = res.data.result;
    },
  },
});

export default useHomeStore;
